module InfoHelper
  def show_sex(sex)
    sex ? "男":"女"  
  end
  
  def distance_of_time(from_time, to_time = 0, include_seconds = false)
    from_time = from_time.to_time if from_time.respond_to?(:to_time)
    to_time = to_time.to_time if to_time.respond_to?(:to_time)
    distance_in_minutes = (((to_time - from_time).abs)/60).round
    
    case distance_in_minutes
    when 0..1           then (distance_in_minutes==0) ? '几秒钟之前' : '一分钟之前'
    when 2..59          then "#{distance_in_minutes} 分钟之前"
    when 60..90         then "1 小时之前"
    when 90..1440       then "#{(distance_in_minutes.to_f / 60.0).round} 小时之前"
    when 1440..2160     then '登陆了 1 天' # 1 day to 1.5 days
    when 2160..2880     then "登陆了 #{(distance_in_minutes.to_f / 1440.0).round} 天" # 1.5 days to 2 days
    else "传说中的挂机王!"
    end
  end
  
  def show_tag_list(tag_list,category)
      ret=""
      tag_list.each do |tag|
        ret=ret+link_to(tag.word, :controller=>"search", :action=>"search_tagword", :id=>tag.id, :category=>category)+" "
      end
      return ret
  end
  
end
